﻿using SqlSugar;

namespace App.WebAPI.Utilty.ApiResult
{
    public static class ApiResultHelper
    {
        public static ApiResult Success(dynamic data)
        {
            return new ApiResult()
            {
                Code = 200,
                Data = data,
                Message = "操作成功",
                Total = 0,
            };
        }

        public static ApiResult Success(dynamic data, RefAsync<int> total, RefAsync<bool> Status)
        {
            return new ApiResult()
            {
                Code = 200,
                Data = data,
                Message = "操作成功",
                Total = total,
                Status = Status
            };
        }
        public static ApiResult Success(dynamic data, RefAsync<bool> Status)
        {
            return new ApiResult()
            {
                Code = 200,
                Data = data,
                Message = "操作成功",
                Status = Status,
            };
        }

        public static ApiResult Error(string message)
        {
            return new ApiResult()
            {
                Code = 500,
                Data = null,
                Message = message,
                Total = 0,
            };
        }

        public static ApiResult NoAuthorization(string message)
        {
            return new ApiResult()
            {
                Code = 401,
                Data = null,
                Message = message,
                Total = 0,
            };
        }
    }
}
